package com.itheima.spider.utils;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * @author Never Say Never
 * @version V1.0
 */
public class C3P0Utils {

    private static DataSource pool = new ComboPooledDataSource(); // 多态：父接口引用指向子类实现！

    /**
     * 获得连接对象
     */
    public static Connection getConnection() throws SQLException {
        return pool.getConnection();
    }

    /**
     * 获得数据源
     */
    public static DataSource getDataSource(){
        return pool;
    }

}
